var a = require("../../../utils/function.js"), t = require("../../../api.js"), i = getApp();

Page({
    data: {
        getAwardButton: !0,
        award: [],
        finishedlist: 0,
        unfinishedlist: 0,
        list: {},
        is: 0,
        idlist: []
    },
    onLoad: function(a) {
        a.uid && i.shareCouponsMessage(a.uid);
    },
    getAwardHandler: function() {
        var a = this.data;
        a.getAwardButton, a.award;
        if (1 == this.data.is) {
            var e = this;
            i.request({
                url: t.driver.keytoget,
                method: "post",
                data: {
                    id: JSON.stringify(e.data.idlist)
                },
                success: function(a) {
                    console.log("一键领取奖励", a), 1 == a.code ? wx.showModal({
                        title: "提示",
                        content: "领取成功"
                    }) : wx.showModal({
                        title: "提示",
                        content: "领取失败"
                    });
                }
            });
        } else wx.showToast({
            title: "暂无可领取奖励",
            icon: "none"
        });
    },
    intoPageHandler: function(t) {
        console.log("参数", t), wx.setStorageSync("current_award", this.data.award[t.currentTarget.dataset.id]), 
        console.log(t.currentTarget.dataset.skip), a.intoPageHandler(t.currentTarget.dataset.skip + "?id=" + t.currentTarget.dataset.id);
    },
    onReady: function() {},
    onShow: function() {
        var a = this;
        i.request({
            url: t.driver.task,
            method: "post",
            data: {},
            success: function(t) {
                a.setData({
                    list: t.data.data.data,
                    finishedlist: t.data.finishedlist,
                    unfinishedlist: t.data.unfinishedlist,
                    unfinished: t.data.unfinished,
                    is: t.data.is,
                    idlist: t.data.idlist
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        var a = this;
        wx.showNavigationBarLoading(), i.request({
            url: t.driver.task,
            method: "post",
            data: {},
            success: function(t) {
                a.setData({
                    list: t.data.data.data,
                    unfinished: t.data.unfinished,
                    is: t.data.unfinished
                }), wx.hideNavigationBarLoading();
            }
        });
    },
    onReachBottom: function() {
        var a = this;
        wx.showNavigationBarLoading();
        var e = 1;
        e += 1, i.request({
            url: t.driver.task,
            method: "post",
            data: {
                page: e
            },
            success: function(t) {
                a.setData({
                    list: t.data.data.data,
                    unfinished: t.data.unfinished,
                    is: t.data.unfinished
                }), wx.hideNavigationBarLoading();
            }
        });
    },
    onShareAppMessage: function() {
        var a = i.shareAppMessage().title, t = i.shareAppMessage().imageUrl, e = i.shareAppMessage().desc, s = i.shareAppMessage().path;
        return console.log(i.shareAppMessage()), {
            title: a,
            imageUrl: t,
            desc: e,
            path: s
        };
    }
});